package com.qf.controller;

import com.qf.pojo.Goods;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

@RestController
public class GoodsController {

    @Value("${server.port}")
    private Integer port;
    @RequestMapping("/query/{id}")
    public String query(@PathVariable("id")Integer id){
        int i =1/id;
        return "查询商品信息!---"+port+":::"+Math.random();
    }
    @GetMapping("/findById/{id}")
    public Goods findById(@PathVariable("id") Integer id){
        int i=1/1;
        System.out.println("id:"+id);
        return new Goods(id,"小杰");
    }
    @GetMapping("/{id}")
    public String findDetails(@PathVariable("id") Integer id){
        System.out.println("id:"+id);
        return "根据id查询商品信息！--"+id;
    }
    @PostMapping("/save")
    public String findGoods(@RequestBody Goods goods){
        System.out.println("id:"+goods);
        return "根据id查询商品信息！--"+goods;
    }
    @GetMapping("/getGoods")
    public String getGoods(@RequestParam Integer id,@RequestParam String name){
        System.out.println("id:"+id+"name:"+name);
        return "查询商品id和名字---"+id+name;
    }
}
